<template>
  <div class="wrapper">
		<div class="header">申请加群列表</div>
		<div class="content">
			<div class="search">
				<div class="text">
					<input type="text" placeholder="搜索">
				</div>
				<span class="search_btn"><img src="img/search_btn.png" alt=""></span>
			</div>
			<div class="list">
				<div class="list_wrapper" v-show="group.ApplyJoinGroup.length>0" @click="goGroupApplyJoinCheck(item)" v-for="item in group.ApplyJoinGroup">
					<div class="list_item">
						<div class="list_item_left">
							<img src="" alt="">
							<span class="item_title">{{item.From_Account}}</span>
						</div>
						<div class="">审核</div>
					</div>
				</div>
			</div>
		</div>
		<div class="footer">
			<div class="footer_item">
				<i class="iconfont icon-duanxinqunfa"></i>
				<div class="controlo"><span>8</span></div>
			</div>
			<div class="footer_item">
				<i class="iconfont icon-kehuqunzu"></i>
				<div class="controlo"><span>100</span></div>
			</div>
			<div class="footer_item">
				<i class="active iconfont icon-user"></i>
				<div class="controlo"><span>99</span></div>
			</div>
		</div>
	</div>
</template>
<script>
import Client from '../../config/common'
export default {
  data () {
    return {
        loginInfo: {}, // 保存登录成功的当前用户信息
        group:{
          ApplyJoinGroup: []
        }
    }
  },
  created () {
    // 登录初始化
    	this.initLogin();
  },
  methods: {
    // 登录初始化
			initLogin() {
				Client.login(this.getLoginInfo);
			},

			// 获得登录成功信息
			getLoginInfo(loginInfo) {
				// 将 登录信息保存在 vue的data里
				this.loginInfo = loginInfo;
				Client.log("登录成功-start");
				Client.log(loginInfo);
				Client.log("登录成功-end");

        // 初始化申请加群列表
				 this.pendencyGroupList();
				 		
				 
				// if(sessionStorage.applyList){
				// 	let data = JSON.parse(sessionStorage.applyList);
				// 	// this.group.ApplyJoinGroup = data;
				// 	console.log(this.group.ApplyJoinGroup);
				// }
				// sessionStorage.applyList = null;
				// 已读上报
				//this.pendencyGroupListRead(); 
		
				
      
      },
  
      // 初始化申请加群列表
      pendencyGroupList() {
				this.pendencyGroupListRead();
        let That = this;
        webim.getPendencyGroup({
              'StartTime': 0,//开始时间
							'Limit': 10 //一次最多获取十条
          }, function(resp) {
						console.log("初始化申请加群列表");
						console.log(resp);

            if(resp.PendencyList){
              for(let i = 0; i< resp.PendencyList.length; i++){
                That.group.ApplyJoinGroup.push(resp.PendencyList[i]);
              }
            }
            console.log(That.group.ApplyJoinGroup);
            console.log("初始化申请加群列表");
        })
			},

			pendencyGroupListRead() {
				let That = this;
				webim.getPendencyGroupRead({
							'ReportTime': 0,//处理时间
							'From_Account': That.loginInfo.identifier //当前登录用户
					}, function(resp) {

						Client.log("已读上报");
						Client.log(That.loginInfo.identifier);
						Client.log(resp);
						Client.log("已读上报");
				}, function(err) {
						Client.log("已读上报失败");
						Client.log(err)
						Client.log("已读上报失败");
				})
			}, 

      // 跳转加群申请验证页面
      goGroupApplyJoinCheck(applyInfo) {
        sessionStorage.applyJoinInfo = JSON.stringify(applyInfo);
        this.$router.push({path: '/groupApplyJoinCheck'});
      }
  }
}
</script>
<style lang="scss">
    @import '../../style/group';
</style>

